package day11;

import java.time.DayOfWeek;
import java.time.LocalDate;

import java.time.LocalTime;
import java.util.Arrays;
import java.util.Scanner;

public class Homework {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入小王的生日（yy-MM-dd）:");
        String s1= sc.next();
        System.out.print("请输入小李的生日（yy-MM-dd）:");
        String s2= sc.next();
        LocalDate ld1=LocalDate.parse(s1);
        LocalDate ld2=LocalDate.parse(s2);
        int n1=ld1.until(ld2).getYears();
        int n2=ld1.until(ld2).getMonths();
        int n3=ld1.until(ld2).getDays();
        System.out.println("他们的生日相差"+n1+"年 "+n2+"月 "+n3+"日");
    }
}


class demo1{
    public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       System.out.print("请输入一个日期(yy-MM-dd):");
       String day=sc.next();
       System.out.print("请输入星期(1~7):");
       int n=sc.nextInt();
       LocalDate ld=LocalDate.parse(day);
       int d=ld.getDayOfWeek().getValue();
       ld=ld.minusDays(d);
       ld=ld.plusDays(n);
       System.out.println("日期为："+ld);

    }
}

class call{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        LocalTime lt=LocalTime.now();
        LocalTime lt1=LocalTime.of(0,10,0);
        System.out.println("开始通话");
        boolean b=true;
        int i=1;
        while(b){
            System.out.println("已经通话："+lt1+":00");
            System.out.print("是否继续通话（y/n）:");
            String s=sc.next();
            if ("y".equals(s)){
                lt1=lt1.plusMinutes(10);
                i++;
                lt=lt.plusMinutes(i*10);
            }else {
                System.out.println("通话时长："+lt1+":00");
                System.out.println("通话时间："+lt);
                b=false;
            }
        }

    }
}

class calendar{
        public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            System.out.print("请输入年份-月份（yy-MM）：");
            String s1=sc.next();
            String s2=s1+"-01";
            LocalDate ld=LocalDate.parse(s2);
            System.out.println("一\t二\t三\t四\t五\t六\t日");
            //\033[31m  红色
            //\033[32m  绿色
            //\033[33m  黄色
            //\033[34m  蓝色
            // ...
            //\033[0m  黑色
            System.out.print("\033[31m");
            int week=ld.getDayOfWeek().getValue();
            for (int i=0;i<week-1;i++) {
                System.out.print("\t");
            }
            int d=ld.lengthOfMonth();
            for (int i=1;i<=d;i++){
                if (ld.withDayOfMonth(i).getDayOfWeek()== DayOfWeek.SUNDAY){
                    System.out.println();
                }
                System.out.print(i+"\t");
            }

        }
}

class allYear {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入年份：");
        String s1 = sc.next();
        print(s1);
    }

    public static void print(String s1) {
        String s2 = s1 + "-01-01";
        LocalDate ld = LocalDate.parse(s2);
        int day = ld.getDayOfWeek().getValue();
        int m[] = new int[12];
        for (int i = 0; i < 12; i++) {
            int month = ld.lengthOfMonth();
            m[i] = month;
            ld = ld.plusMonths(1);
        }
        int k = day;
        StringBuilder str = new StringBuilder();
        for (int l = 0; l < day; l++) {
            str.append("  ");
        }
        System.out.println("一  二  三  四  五  六  日");
        System.out.print(str);

        for (int i = 0; i < 12; i++) {
            for (int j = 1; j <= m[i]; j++) {
                k++;
                if (k == 7) {
                    k = 0;
                    System.out.println();
                }
                if (j < 10) {
                    System.out.print("0" + j + " ");
                } else {
                    System.out.print(j + " ");
                }
            }
        }
    }
}

class demo2{
    public static void main(String[] args) {
         Scanner sc=new Scanner(System.in);
         System.out.print("请输入年份-月份（yy-MM）：");
         String s1=sc.next();
         String s2=s1+"-01";
         LocalDate ld=LocalDate.parse(s2);
         System.out.println("一\t二\t三\t四\t五\t六\t日");
         int d=ld.getMonthValue();
         for (int i=1;i<=d;i++){
             if (ld.withDayOfMonth(i).getDayOfWeek()== DayOfWeek.SUNDAY){
                 System.out.println();
             }
             System.out.print(i+"\t");
         }

    }
}

